/* checkmpe -- computes the logweight of an MPE solution */

#include <stdio.h>

#include "graph.h"
#include "parse.h"

int main(int argc, char ** argv)
{
  char * model_fname;
  char * mpe_fname;
  Graph_t * model;
  int num_inst;                             /* number of instances */
  Instance_t * p_inst;                       /* array of instances */
  int i;
  
  if (argc != 3)
  {
    fprintf(stderr, "Usage: checkmpe <graph-file> <mpe-file-name>\n");
    return 1;
  }

  model_fname = argv[1];
  mpe_fname = argv[2];
  
  model = parse_model(model_fname);

  parse_mpe(mpe_fname, model, &num_inst, &p_inst);
  
  for (i=0; i<num_inst; i++)
  {
    printf("Instance %d: log-weight %lf\n", i,
           graph_joint_factor(model, (p_inst+i)->inst_p_val));
  }
  
  return 0;
}
